﻿using System;
using System.Web.UI;
using KPIS.GERP.GHRMS.APP.Classes;
using Telerik.Web.UI;

namespace KPIS.GERP.GHRMS.APP.App_UI.Forms
{
    public partial class PS_EmployeesDtls : System.Web.UI.Page
    {
        private SsMng ssMng = new SsMng();
        private Main main = new Main();

        protected void Page_Load(object sender, EventArgs e)
        {
            string strQueryString = Request.QueryString["Sequence"];
            if (strQueryString == "ESS")
            {
                Session["emp_seq"] = ssMng.EmpSeq;
            }
            else
            {
                Session["emp_seq"] = strQueryString;
            }

            RadTabStrip1.Enabled = Session["emp_seq"].ToString().Length != 0;

            if (!IsPostBack)
            {
                AddPageView(RadTabStrip1.FindTabByText("ข้อมูลเบื้องต้น"));
            }
        }

        protected void RadMultiPage1_PageViewCreated(object sender, RadMultiPageEventArgs e)
        {
	        try
			{
		        string userControlName = "../UserControls/" + e.PageView.ID + "Info.ascx";
		        userControlName = e.PageView.ID == "PS_HisPrivate"
			                          ? "../UserControls/PS_HisPrivateEdit.ascx"
			                          : userControlName;

		        Control userControl = Page.LoadControl(userControlName);
		        userControl.ID = e.PageView.ID + "_userControl";
				e.PageView.Controls.Add(userControl);
	        }
	        catch (Exception ex)
	        {
                main.MessageAlert2(Page, ex);
	        }
        }

        private void AddPageView(RadTab tab)
        {
            RadPageView pageView = new RadPageView();
            pageView.ID = tab.Value;
            RadMultiPage1.PageViews.Add(pageView);
            tab.PageViewID = pageView.ID;
        }

        protected void RadTabStrip1_TabClick(object sender, RadTabStripEventArgs e)
        {
            try
            {
                AddPageView(e.Tab);
                e.Tab.PageView.Selected = true;
            }
            catch (Exception ex)
            {
                main.MessageAlert2(Page, ex);
            }
        }
    }
}
